﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Domain;
using Lswweb.Model;


namespace Lswweb.Controls
{
    public class DisplayOrderHandler : ModelHandler
    {
        protected override void Handler(int id,SiteModule type)
        {
            try
            {
                switch (type)
                {
                    case SiteModule.News:
                        News.UpdateDisplayOrder(Convert.ToInt32(id), DisplayOrder);
                        break;
                    case SiteModule.Product:
                        Products.UpdateDisplayOrder(Convert.ToInt32(id), DisplayOrder);
                        break;
                    default:
                        SiteContext.RenderMessage(ExceptionType.PageNotFond, SiteContext.Current.ReferrerUrl);
                        break;
                }
            }
            catch (FormatException)
            {
                SiteContext.RenderMessage(ExceptionType.UnknownError, SiteContext.Current.Context.Request.UrlReferrer.PathAndQuery);
            }
        }

        private int DisplayOrder
        {
            get
            {
                return Convert.ToInt32(SiteContext.Current.SearchKey);
            }
        }
    }
}
